﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

using Ordinaire.Db;
using Ordinaire.Commerce.Db;
using Ordinaire.Security;

namespace Ordinaire.Commerce.Test
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            // Setup test database
            SetupDb();

            string[] my_args = { Assembly.GetExecutingAssembly().Location, "/wait" };

            int returnCode = NUnit.ConsoleRunner.Runner.Main(my_args);

            if (returnCode != 0)
                Console.Beep();
        }

        /// <summary>
        /// Setup database for testing.
        /// </summary>
        static void SetupDb()
        {
            CContext context = DbFactory.Instance.CreateDataContext<CContext>();
            if (context.DatabaseExists())
            {
                context.DeleteDatabase();
            }
            context.CreateDatabase();
        }
    }
}
